package com.beta.cat.config.log;

import org.apache.logging.log4j.core.LogEvent;
import org.apache.logging.log4j.core.config.plugins.Plugin;
import org.apache.logging.log4j.core.lookup.AbstractLookup;
import org.apache.logging.log4j.core.lookup.StrLookup;

@Plugin(name = "spring", category = StrLookup.CATEGORY)
public class SpringPropertiesLookup extends AbstractLookup {
    @Override
    public String lookup(LogEvent event, String key) {
        return Log4j2SpringEnvSupportConfig.ctx == null ? null : Log4j2SpringEnvSupportConfig.ctx.getEnvironment().getProperty(key);
    }
}
